class Solution(object):
    def firstMissingPositive(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        result = 0
        m = {}
        positive_nums = 0
        for num in nums:
            if num > 0 and num not in m:
                positive_nums += 1
                m[num] = 1
        for i in range(1, positive_nums+1):
            if i not in m:
                result = i
                return result
        return positive_nums + 1
